<!DOCTYPE html>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>单次票查询</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<jsp:include page="/common/commonCss.jsp"/>
	<jsp:include page="/common/commonJs.jsp"/>
	<script src="${basePath}commonJs/jquery.imageScroller.js"></script>
	<script src="${basePath }resources/membership/finger.js"></script>
	<script type="text/javascript">
	var base = "${basePath}";
	
		$(function() {
			$("#listBox").imageScroller({
				next : "btnNext",
				prev : "btnPrev",
				frame : "list",
				child : "li",
				auto : false
			});
		});

		// 根据会员姓名或监护人号码查询
		function queryMember(obj) {
			var type2="${type}";//获取类型传值
			$("#nameOrTel").val(obj.value);
			if (obj.value == "") {
				alertError(getMessage($common_msg_empty, "查询条件"));
				return false;
			}
			$("#list li").remove();
			$('#container').show();
			$.ajax({
				cache : false,
				type : "post",
				dataType : "json",
				url : "${basePath}management/site/queryMember.shtml",
				data :$("#conditionForm").serialize(),
				complete : function() {
				},
				success : function(data) {//data为返回的数据，在这里做数据绑定
					if (data == null || data.length == 0) {
						alertInfo("没有匹配的记录！");
					} else {
						trimJsonArray(data);
						var li;
						for (var i = 0; i < data.length; i++) {
							var member = data[i];
							var status=member.status;
						//if(status!=5){//排除新建的
							var memName="";
							if(member.memName!=null){
								memName=member.memName;
								if(memName.length>5){
									memName=memName.substring(0, 5)+"...";
								}
							}
							var memType=member.memType;
							if(memType=="4"){
								
								li = '<li title='+member.memName+'>';
								li +='<a href="${basePath}management/site/querySaleDetail.shtml?userId=' + member.pkMemId + '&type=' + type2 + '&nameOrTel= " >';
								var imagePath=member.imagePath;
								if(null!=imagePath && ""!=imagePath){
									li += '		<p class="coll_img"><img width="102" height="136" src="${basePath}common/showImage.shtml?imagePath=' + imagePath + ' "></p>';
								}else{
									li += '		<p class="coll_img"><img width="102" height="136" src="${basePath }commonCss/images/index_02.png"></p>';
								}
								
								li += ' 		<dl class="collection_t_l_dl">';
								li += ' 		<dd>&nbsp;'
										+ memName + '<span class="fr">销售</span>' 
										+ '</dd>';
								li += ' 		</dl>';
								li += '	</a>';
								li += '</li>';
								$("#list").append(li);
								
							}else{
								var isSingleTicket=false;
								//判断此会员下是否有单次票
								$.ajax({
									cache: false,
							        async: false,
									type : "get",
									dataType : "json",
									url : base + "membership/single/checkEnableSingleByMemberId.shtml?memberId=" + member.pkMemId,
									error : function(XMLHttpRequest) {
										ajaxError(XMLHttpRequest);
									},
									success : function(data) {
										if (data == "1") {
											// 已买单次票
											isSingleTicket=true;
										} else{
											// 未买单次票
											isSingleTicket=false;
										}
									}
								});
								
							//判断小朋友头像背景色
							var bgColor="coll_img colle_img_lv";
							var isBlack=member.isBlack;
							if(isBlack==1 || status==3 || status==4 || status==null || status==''){//红色-问题（过期/黑名单/停卡）
								if((member.inTime!=null && member.inTime!="") && (member.outTime==null || member.outTime=="")){//绿色-场内
									bgColor="coll_img colle_img_lv";
								}else{//灰色-场外
									if(status==4 && isSingleTicket==true){
										bgColor="coll_img colle_img_ccc";
									}else{
										bgColor="coll_img colle_img_red";
									}
								}
							}else{
								if((member.inTime!=null && member.inTime!="") && (member.outTime==null || member.outTime=="")){//绿色-场内
									bgColor="coll_img colle_img_lv";
								}else{//灰色-场外
									bgColor="coll_img colle_img_ccc";
								}
							}
							
							//跳转到详情页面判断
							var aUrl='';
							var type="${type}";
							if(isBlack==1 || status==3 || status==4 || status==null || status==''){//问题客人照片，弹出框提示不能进场的具体错误信息
								if(isBlack==1){
									aUrl='<a href="javacript:" onclick=alertInfo("黑名单用户无权限操作，谢谢！");>';
								}
								if(status==3){
									var memTypeString = "会员已过期，请续费，谢谢！";
									if(memType=="2"){
										memTypeString = "非会员已过期，请购买单次票，谢谢！";
									}
									aUrl='<a href="javacript:" onclick=alertInfo("' + memTypeString + '");>';
								}
								if(status==4){
									if((member.inTime!=null && member.inTime!="") && (member.outTime==null || member.outTime=="")){//绿色-场内
										//不做操作
										aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + ' " >';//&inTime=' + member.inTime + '&outTime=' + member.outTime + '
									}else{//灰色-场外
										if(isSingleTicket==true){
											// 已买单次票
											aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + ' " >';
										}else{
											// 未买单次票
											aUrl='<a href="javacript:" onclick=alertInfo("会员已停卡，谢谢！");>';
										}
									}
								}
							}else{
								if(type=="1"){
									if (member.memType == 1 || member.memType == 2){//2.	点击页面中会员或非会员照片，跳转入场客人选择页面
										aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + ' " >';//&inTime=' + member.inTime + '&outTime=' + member.outTime + '
									}else{//3.	点击页面中销售照片，跳转访客入场页面
										aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + ' " >';//&inTime=' + member.inTime + '&outTime=' + member.outTime + '
									}
								}else{
									if((member.inTime!=null && member.inTime!="") && (member.outTime==null || member.outTime=="")){//绿色-场内
										if (member.memType == 1 || member.memType == 2){//2.	点击页面中会员或非会员照片，跳转入场客人选择页面
											aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + ' " >';//&inTime=' + member.inTime + '&outTime=' + member.outTime + '
										}else{//3.	点击页面中销售照片，跳转访客入场页面
											aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + ' " >';//&inTime=' + member.inTime + '&outTime=' + member.outTime + '
										}
									}else{//灰色-场外
										aUrl='<a href="javacript:" onclick=alertInfo("只能选择场内会员，谢谢！");>';
									}
								}
							}
							
							var memberCardName="";
							if(member.memberCardName!=null){
								memberCardName=member.memberCardName;
							}
							li = '<li title='+member.memName+'>';
							li +=aUrl;
							li += '		<p class="' + bgColor + '"><img width="102" height="136" src="${basePath}common/showImage.shtml?imagePath='
									+ member.imagePath + ' "></p>';
							li += ' 		<dl class="collection_t_l_dl">';
							li += ' 		<dd>'
									+ memName + '  ' + member.age + '岁 ' 
									+ (member.isVip == 1 ? '<a  style="color:red">VIP</a>' : ' ') 
									+ '</dd>';
							if (member.memType == 1) {
								li += ' 		<dd class="f11">会员 <span class="f9">'
										+ member.pkMemId
										+ '</span></dd>';
								li += ' 		<dd>' + memberCardName
										+ '</dd>';
							} else if (member.memType == 2) {
								li += ' 		<dd class="f11">非会员</dd>';
								li += ' 		<dd></dd>';
							} else if (member.memType == 3) {
								li += ' 		<dd class="f11">访客</dd>';
								li += ' 		<dd></dd>';
							}
							li += ' 		</dl>';
							li += '	</a>';
							li += '</li>';
							$("#list").append(li);
							
							}
						}
					}
					return;
				}
			});
		}
		
		function  collectFingerprint() {
			try {
				var data = collectFingerFeatrue();
				if (data != "") {
					queryMemberByFingerprint(data);
				}
			} catch (e) {
				return "";
			}
		}

		// 根据指纹查询
		function queryMemberByFingerprint(fingerprint) {
			var type2="${type}";//获取类型传值
			
			if (fingerprint == "") {
				alertError(getMessage($common_msg_empty, "指纹采集失败，请重新录入指纹"));
				return false;
			}
			$("#fingerprint").val(fingerprint);
			$("#list li").remove();
			$('#container').show();
			$.ajax({
				cache : false,
				type : "post",
				dataType : "json",
				url : "${basePath}management/site/queryMemberByFingerprint.shtml",
				data :$("#fpForm").serialize(),
				success : function(member) {//data为返回的数据，在这里做数据绑定
					if (member == null) {
						alertInfo("没有匹配的记录！");
					} else {
						trimJsonArray(member);
						var li;
						var status=member.status;
					//if(status!=5){//排除新建的
						var memName="";
						if(member.memName!=null){
							memName=member.memName;
							if(memName.length>5){
								memName=memName.substring(0, 5)+"...";
							}
						}
						
						var memType=member.memType;
						
						if(memType=="4"){
							
							li = '<li title='+member.memName+'>';
							li +='<a href="${basePath}management/site/querySaleDetail.shtml?userId=' + member.pkMemId + '&type=' + type2 + '&nameOrTel= " >';
							var imagePath=member.imagePath;
							if(null!=imagePath && ""!=imagePath){
								li += '		<p class="coll_img"><img width="102" height="136" src="${basePath}common/showImage.shtml?imagePath=' + imagePath + ' "></p>';
							}else{
								li += '		<p class="coll_img"><img width="102" height="136" src="${basePath }commonCss/images/index_02.png"></p>';
							}
							
							li += ' 		<dl class="collection_t_l_dl">';
							li += ' 		<dd>&nbsp;'
									+ memName + '<span class="fr">销售</span>' 
									+ '</dd>';
							li += ' 		</dl>';
							li += '	</a>';
							li += '</li>';
							$("#list").append(li);
							
						}else{
						
							var isSingleTicket=false;
							//判断此会员下是否有单次票
							$.ajax({
								cache: false,
						        async: false,
								type : "get",
								dataType : "json",
								url : base + "membership/single/checkEnableSingleByMemberId.shtml?memberId=" + member.pkMemId,
								error : function(XMLHttpRequest) {
									ajaxError(XMLHttpRequest);
								},
								success : function(data) {
									if (data == "1") {
										// 已买单次票
										isSingleTicket=true;
									} else{
										// 未买单次票
										isSingleTicket=false;
									}
								}
							});
							
						//判断小朋友头像背景色
						var bgColor="coll_img colle_img_lv";
						var isBlack=member.isBlack;
						if(isBlack==1 || status==3 || status==4 || status==null || status==''){//红色-问题（过期/黑名单/停卡）
							if((member.inTime!=null && member.inTime!="") && (member.outTime==null || member.outTime=="")){//绿色-场内
								bgColor="coll_img colle_img_lv";
							}else{//灰色-场外
								if(status==4 && isSingleTicket==true){
									bgColor="coll_img colle_img_ccc";
								}else{
									bgColor="coll_img colle_img_red";
								}
							}
						}else{
							if((member.inTime!=null && member.inTime!="") && (member.outTime==null || member.outTime=="")){//绿色-场内
								bgColor="coll_img colle_img_lv";
							}else{//灰色-场外
								bgColor="coll_img colle_img_ccc";
							}
						}
						
						//跳转到详情页面判断
						var aUrl='';
						var type="${type}";
						if(isBlack==1 || status==3 || status==4 || status==null || status==''){//问题客人照片，弹出框提示不能进场的具体错误信息
							if(isBlack==1){
								aUrl='<a href="javacript:" onclick=alertInfo("黑名单用户无权限操作，谢谢！");>';
							}
							if(status==3){
								var memTypeString = "会员已过期，请续费，谢谢！";
								if(memType=="2"){
									memTypeString = "非会员已过期，请购买单次票，谢谢！";
								}
								aUrl='<a href="javacript:" onclick=alertInfo("' + memTypeString + '");>';
							}
							if(status==4){
								if((member.inTime!=null && member.inTime!="") && (member.outTime==null || member.outTime=="")){//绿色-场内
									//不做操作
									aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + '&inTime=' + member.inTime + '&outTime=' + member.outTime + ' " >';
								}else{//灰色-场外
									if(isSingleTicket==true){
										// 已买单次票
										aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + ' " >';
									}else{
										// 未买单次票
										aUrl='<a href="javacript:" onclick=alertInfo("会员已停卡，谢谢！");>';
									}
								}
							}
						}else{
							if(type=="1"){
								if (member.memType == 1 || member.memType == 2){//2.	点击页面中会员或非会员照片，跳转入场客人选择页面
									aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + '&inTime=' + member.inTime + '&outTime=' + member.outTime + ' " >';
								}else{//3.	点击页面中销售照片，跳转访客入场页面
									aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + '&inTime=' + member.inTime + '&outTime=' + member.outTime + ' " >';
								}
							}else{
								if((member.inTime!=null && member.inTime!="") && (member.outTime==null || member.outTime=="")){//绿色-场内
									if (member.memType == 1 || member.memType == 2){//2.	点击页面中会员或非会员照片，跳转入场客人选择页面
										aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + '&inTime=' + member.inTime + '&outTime=' + member.outTime + ' " >';
									}else{//3.	点击页面中销售照片，跳转访客入场页面
										aUrl='<a href="${basePath}management/site/queryMemberDetail.shtml?memberId=' + member.pkMemId + '&type=' + type + '&inTime=' + member.inTime + '&outTime=' + member.outTime + ' " >';
									}
								}else{//灰色-场外
									aUrl='<a href="javacript:" onclick=alertInfo("只能选择场内会员，谢谢！");>';
								}
							}
						}
						
						var memberCardName="";
						if(member.memberCardName!=null){
							memberCardName=member.memberCardName;
						}
						li = '<li title='+member.memName+'>';
						li +=aUrl;
						li += '		<p class="' + bgColor + '"><img width="102" height="136" src="${basePath}common/showImage.shtml?imagePath='
								+ member.imagePath + ' "></p>';
						li += ' 		<dl class="collection_t_l_dl">';
						li += ' 		<dd>'
								+ memName + '  ' + member.age + '岁 ' 
								+ (member.isVip == 1 ? '<a  style="color:red">VIP</a>' : ' ') 
								+ '</dd>';
						if (member.memType == 1) {
							li += ' 		<dd class="f11">会员 <span class="f9">'
									+ member.pkMemId
									+ '</span></dd>';
							li += ' 		<dd>' + memberCardName
									+ '</dd>';
						} else if (member.memType == 2) {
							li += ' 		<dd class="f11">非会员</dd>';
							li += ' 		<dd></dd>';
						} else if (member.memType == 3) {
							li += ' 		<dd class="f11">访客</dd>';
							li += ' 		<dd></dd>';
						}
						li += ' 		</dl>';
						li += '	</a>';
						li += '</li>';
						$("#list").append(li);
						}
					$('#container').show();
					return;
				}}
			});
		}
		
 function inoutPaiReserve(type){
	 window.location.href='${basePath }parreserve/inOutManagementPar.shtml?type='+type;
 }
	</script>
</head>
<body class="bg">


<style>
#btnPrev, #btnNext, #listBox
        {
            float: left;
        }
        
        #btnPrev, #btnNext
        {
            width: 30px;
            height: 18px;
            line-height: 18px;
            padding: 41px 0;
            text-align: center;
        }
#listBox
{
            width: 700px;
            height: 276px;
            overflow: hidden;
        }
        
#container
        {
            width: 800px;
            height: 276px;
            position: absolute;

        }
</style>

<div class="content m_auto ">
	<div class="content_l mt10">
    	<ul>
    		<shiro:hasPermission name="management/site/locPerManager.shtml?type=1">
				<li <c:if test="${type==1 }">class="content_hover"</c:if>><a href="${basePath}management/site/locPerManager.shtml?type=1"><i class="nav_icon_c"></i><br>入场管理</a></li>
			</shiro:hasPermission>
        	<shiro:hasPermission name="management/site/locPerManager.shtml?type=2">
            	<li <c:if test="${type==2 }">class="content_hover"</c:if>><a href="${basePath}management/site/locPerManager.shtml?type=2"><i class="nav_icon_i"></i><br>出场管理</a></li>
            </shiro:hasPermission>
            <shiro:hasPermission name="management/site/locPerMemer.shtml">
            	<li><a href="${basePath}management/site/locPerMemer.shtml"><i class="nav_icon_j"></i><br>场内人员</a></li>
            </shiro:hasPermission>
        </ul>
    </div>
    <div class="content_r mt10">
    	<div class="payment_l mt30 tc">
    		<c:if test="${type==1 }">
    			<input type="button" value="派对团体入场" class="btn" onClick="inoutPaiReserve(1);">
    		</c:if>
        	<c:if test="${type==2 }">
    			<input type="button" value="派对团体出场" class="btn" onClick="inoutPaiReserve(2);">
    		</c:if>
        </div>
        <div class="payment_r mt30">
        	<div style="display:none;">
			<object classid="clsid:82C2415C-1EC7-41ED-A6F0-2BCA3B4216E2" id="finger" codebase="${basePath }plugin/Ferly727.ocx">
			  <param name="_ExtentX" value="635">
			  <param name="_ExtentY" value="582">
			  <param name="_StockProps" value="64">
			  <param name="Enabled" value="1">
			</object>
		</div>
        	<div class="ml60 payment_tab">
                <ul id="tab_a" class="f14 fixed">
                   <li onClick="javascript:$('#container').hide();">扫描指纹查询</li>
                   <li onClick="javascript:$('#container').hide();">条件查询</li>
                </ul>
                <ul id="tab_conbox_a">
                    <li class="tc p20">
                    	<form id="fpForm" method="post">
                    	<a href="#" onClick="collectFingerprint();">
                    		<img src="${basePath}commonCss/images/zhiwen.gif">
                    		<input type="hidden" name="fingerprint" id="fingerprint">
                    	</a>
                    	</form>
                    </li>
                    <li class="tc p20">
                    		姓名/电话：<input type="text" class="iput_t mt20"  onkeydown="if(event.keyCode==13) {queryMember(this);}">
                    	<form id="conditionForm" method="post">
		        	<input type="hidden" name="nameOrTel" id="nameOrTel">
                    	</form>
                    </li>
                </ul>
            </div>
            <div id="container" class="collection_b ml50 fixed w800 border_top" style="display:none;">
            	<div id="btnNext"><a href="javascript:void(0);" class="collection_t_l"></a></div>
            	 <div id="listBox">
            	<ul id="list">
                 
                </ul>
                </div>
                <div id="btnPrev"><a href="javascript:void(0);" class="collection_t_r"></a></div>
            </div>
        </div>
         <div class="clear"></div>
        <div class="btm_btn mt30">
        	<dl>
               <!-- <dd><a href="javascript:alert('开发中……');"><input type="button" class="btn" value="下一步"></a>-->
            </dl>
        </div>
    </div>
</div>

</body>
</html>